package zisu.algorithm.algorithm.AVLTree;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        System.out.println("pride and prejudice");
        ArrayList<String> words = new ArrayList<>();
        if(FileOperation.readFile("pride-and-prejudice.txt",words)){
            System.out.println("Total words:"+words.size());
            AVLTree<String,Integer> avlTree = new AVLTree<>();
            for(String word:words){
                if(avlTree.contains(word)){
                    avlTree.set(word,avlTree.get(word)+1);
                }else {
                    avlTree.add(word,1);
                }
            }
            System.out.println("total different words:"+avlTree.getSize());
            System.out.println("Frequency of PRIDE:"+avlTree.get("pride"));
            System.out.println("Frequency of PREJUDICE:"+avlTree.get("prejudice"));

        }
    }

}
